package com.artPreter.controller;


import com.artPreter.pojo.*;
import com.artPreter.pojo.EventExhibition;
import com.artPreter.service.IEventExhibitionService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 活动展览表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2025-01-05
 */
@RestController
@RequestMapping("/eventExhibition")
public class EventExhibitionController {


    @Autowired
    private IEventExhibitionService eventExhibitionService;

    /**
     * 活动展览分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody EventExhibition eventExhibition) {
        IPage<EventExhibition> eventExhibitionIPage = eventExhibitionService.getPage(currentPage, size, eventExhibition);
        return Result.success(eventExhibitionIPage);
    }

    /**
     *  添加活动展览
     * @param eventExhibition
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody EventExhibition eventExhibition) {
        eventExhibitionService.add(eventExhibition);
        return Result.success();
    }

    /**
     *  修改活动展览
     * @param eventExhibition
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody EventExhibition eventExhibition) {
        eventExhibitionService.edit(eventExhibition);
        return Result.success();
    }

    /**
     * 删除活动展览
     * @param eventExhibition
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody EventExhibition eventExhibition){
        eventExhibitionService.delete(eventExhibition);
        return Result.success();
    }

    /**
     * 获取活动展览列表
     * @param eventExhibition
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody EventExhibition eventExhibition){
        List<EventExhibition> result = eventExhibitionService.getList(eventExhibition);
        return Result.success(result);
    }


    @PostMapping("/getInfo")
    public Result getInfo(@RequestBody EventExhibition eventExhibition){
        EventExhibition result = eventExhibitionService.getInfo(eventExhibition);
        return Result.success(result);
    }

    @PostMapping("/getPageNoRelative")
    public Result getPageNoRelative(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody EventExhibition eventExhibition){
        IPage<EventExhibition> eventExhibitionIPage = eventExhibitionService.getPageNoRelative(currentPage,size,eventExhibition);
        return Result.success(eventExhibitionIPage);
    }

    @PostMapping("/getPageRelative")
    public Result getPageRelative(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody EventExhibition eventExhibition){
        IPage<EventExhibition> eventExhibitionIPage = eventExhibitionService.getPageRelative(currentPage,size,eventExhibition);
        return Result.success(eventExhibitionIPage);
    }

    @PostMapping("/addToRelative")
    public Result addToRelative(@RequestBody EventExhibition eventExhibition){
        eventExhibitionService.addToRelative(eventExhibition);
        return Result.success();
    }

    @PostMapping("/removeEventExhibitionRelative")
    public Result removeArticleRelative(@RequestBody EventExhibition eventExhibition){
        eventExhibitionService.removeEventExhibitionRelative(eventExhibition);
        return Result.success();
    }



}
